require.config({
    baseUrl: 'plugins/',
    'paths' : {
        'jquery' : 'jquery/jquery-3.1.1.min',
        'angular' : 'angular/angular.min',
        'angular-animate' : 'angular/angular-animate.min',
        'angular-ui-router' : 'angular/angular-ui-router.min',
        'framework7' : 'framework7/framework7'
    },
    shim: {
        'angular': {
            exports: 'angular'
        },
        'angular-ui-router': {
            deps: ['angular']
        },
        'angular-animate': {
            deps: ['angular']
        },
        'framework7' : {
            exports: 'framework7',
            deps : ['jquery']
        }
    }
});

require(['jquery', 'angular', 'framework7', 'angular-ui-router', 'angular-animate'], function($, angular, framework7){
    angular.element(document).ready(function () {
        angular.bootstrap(document, ['BieTuoYan']);
    });
    angular.module('BieTuoYan', ['ui.router', 'ngAnimate']).config(['$stateProvider', '$urlRouterProvider',
        function($stateProvider, $urlRouterProvider) {
            $urlRouterProvider.otherwise('/');
            $stateProvider.state('app', {
                url: '/',
                views : {
                    side : {
                        controller: 'SideController',
                        templateUrl: 'view/side.html',
                    },
                    header : {
                        controller: 'HeaderController',
                        templateUrl: 'view/header.html',
                    },
                    navbar : {
                        controller: 'NavbarController',
                        templateUrl: 'view/navbar.html',
                    },
                    content : {
                        controller: 'HomeController',
                        templateUrl: 'view/home.html',
                    }
                }
            }).state('app.everyday', {
                url: 'everyday/',
                views : {
                    'content@' : {
                        controller: 'TwoController',
                        templateUrl: 'view/everyday.html',
                    }
                }
            });
        }
    ]).controller('SideController', ['$scope', function($scope) {
        $scope.username = 'Drunk';
    }]).controller('HomeController', ['$scope', function($scope) {

    }]).controller('TwoController', function() {

    }).controller('HeaderController', function() {

    }).controller('NavbarController', function() {

    }).run(['$rootScope', '$location', function ($rootScope, $location) {
        $rootScope.$on('$stateChangeSuccess', function(event, $target, toParams, fromState, fromParams){
            $rootScope.$evalAsync(function(){
                console.log(53453);
                new Framework7;
                $('.toolbar-inner a').removeClass('active');
                $('.toolbar-inner a[ui-sref="'+$target.name+'"]').addClass('active');
            });
            console.log(123);
        });
    }]);
});